package com.test.utils.search.log;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.FactoryBean;

public class LoggerFactoryBean implements FactoryBean<Logger> {

	private Logger logger;

	/**
	 * The name of the log.
	 * <p>This property is required.
	 * @param logName the name of the log
	 */
	public void setLogName(String logName) {
		this.logger = Logger.getLogger(logName);
	}


	public void afterPropertiesSet() {
		if (this.logger == null) {
			throw new IllegalArgumentException("'logName' is required");
		}
	}

	public Logger getObject() {
		return this.logger;
	}

	public Class<? extends Logger> getObjectType() {
		return (this.logger != null ? this.logger.getClass() : Logger.class);
	}

	public boolean isSingleton() {
		return true;
	}

}
